﻿using System;
using System.Collections.Generic;

namespace Domain.Models
{
    [Serializable]
    public class Question
    {
        private readonly List<Answer> answers = new List<Answer>(); 

        public IEnumerable<Answer> Answers
        {
            get { return answers.AsReadOnly(); }
        }

        public long Id { get; private set; }

        public string TrueAnswer { get; private set; }

        public string Text { get; set; }

        public Question(string text)
        {
            Text = text;
            Id = GetHashCode();
        }

        public void SetTrueAnswer(string trueAnswer)
        {
            this.TrueAnswer = trueAnswer;
        }

        public bool AnswerToQuestion(string answer)
        {
            if (answer == null)
                return false;

            return answer == TrueAnswer;
        }

        public void AddAnswer(string answer)
        {
            answers.Add(new Answer(answer));
        }

        public void AddTrueAnswer(string trueAnswer)
        {
            AddAnswer(trueAnswer);
            this.TrueAnswer = trueAnswer;}

        public void RemoveAnswer(Answer answer)
        {
            // check null, exists

        }
    }
}